import http from './http'
import { getUser } from '../auth'

export const getPage = async(index, pageSize) =>{
    let user = getUser()
    return await http.fetchGet(`/api/user/page/${user.account.id}?pageIndex=${index}&pageSize=${pageSize}`);
}

export const fullInfo = async(username) =>{
    return await http.fetchGet(`/api/user/full/${username}`);
} 

export const save = async(item) =>{
    let user = getUser()
    return await http.fetchPost(`/api/user/save`, {
        ...item,
        company : user.account.id
    });
}

export const update = async(item) =>{
    let user = getUser()
    return await http.fetchPost(`/api/user/update`, {
        ...item,
        company : user.account.id
    });
}

export const del = async(item) =>{
    return await http.fetchPost(`/api/user/delete?id=${item.username}`);
}